from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
from pydantic.types import UUID4
from app.schemas.archivable import Archivable

# 基础模型
class BroadcastPresetsLibraryBase(BaseModel):
    category_name: Optional[str] = Field(description="播报文案预设分类名")
    # usage_count: int = 0

# 创建模型
class BroadcastPresetsLibraryCreate(BroadcastPresetsLibraryBase):
    # category_name: Optional[str] = Field(description="播报文案预设分类名")
    pass
# 更新模型
class BroadcastPresetsLibraryUpdate(BroadcastPresetsLibraryBase):
    pass

# 数据库基础模型
class BroadcastPresetsLibraryInDBBase(BroadcastPresetsLibraryBase, Archivable):
    id: UUID4
    usage_count: Optional[int]
    created_at: Optional[datetime]
    updated_at: Optional[datetime]

    # class Config:
    #     from_attributes = True
    #     protected_namespaces = ()
        # allow_population_by_field_name = True

# 返回模型
class BroadcastPresetsLibrary(BroadcastPresetsLibraryInDBBase):
    pass

# 数据库模型
class BroadcastPresetsLibraryInDB(BroadcastPresetsLibraryInDBBase):
    user_id: Optional[UUID4]
